<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/admin/commons/taglib.jsp"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>后台管理</title>
    <script type="text/javascript">
        $(function(){
            $("#post").addClass("active");
            $("#post").find("ul li").eq(1).addClass("active");
        })
    </script>
</head>
<body>

    <div class="admin">
         <form id="form" method="post" action="post!deletebyid.action">
            <div class="panel admin-panel">
                <div class="panel-head"><strong>文章列表</strong></div>
                <div class="padding border-bottom">
                    <input type="button" id="selectall" class="button button-small checkall"  checkfor="id" value="全选" />
                    <a href="<%=request.getContextPath() %>/admin/post/post.jsp"><input type="button" class="button button-small border-green" value="添加文章" /></a>
                    <input type="button" onClick="submit()" class="button button-small border-yellow" value="批量删除" />

                </div>

                <table class="table table-hover">
                    <tr><th width="100">选择</th><th width="120">作者</th><th width="200">图片</th><th width="400">文章标题</th><th width="200">时间</th><th width="200">操作</th></tr>

                   <s:iterator value="posts">
                    <tr>
                        <td><input type="checkbox" class="choose" name="id" value="<s:property value="id"/>" /></td>
                        <td><s:property value="writer"/></td>
                        <td><a href="#" target="_blank"><img height="70" width="70" src="<%=request.getContextPath() %>/<s:property value="img"/>"target="_blank" /></a></td>
                        <td><a href="#" target="_blank"><s:property value="title"/></a></td>
                        <td><s:property value="time"/></td>
                        <td><a class="button border-blue button-little" href="post!update.action?id1=<s:property value="id"/>&page=${page}" >修改</a></td>
                    </tr>
                    </s:iterator>
                </table>
            </div>
         </form>

        <div class="panel-foot text-center">
            <ul class="pagination"><li>
                <s:if test="page==1">
                <a href="#">上一页</a>
                </s:if>
                <s:else>
                <a href="post!findall.action?page=${page-1}">上一页</a>
                </s:else>
                </li>
            </ul>

            <ul class="pagination pagination-group">
                <s:iterator begin="1" end="allpage" var="i">
                    <s:if test="#i==page">
                       <li class="active"><a href="post!findall.action?page=<s:property value="#i"/>"><s:property value="#i"/></a></li>
                    </s:if>
                    <s:else>

                               <li><a href="post!findall.action?page=<s:property value="#i"/>"><s:property value="#i"/></a></li>
                    </s:else>
                </s:iterator>
            </ul>


            <ul class="pagination"><li>
                <s:if test="page==totalPage">
                <a href="#">下一页</a>
                 </s:if>
                <s:else>
                <a href="post!findall.action?page=${page+1}">下一页</a>
                </s:else>
                </li>
            </ul>
        </div>
        
    </div>

    <script type="text/javascript">
        function submit(){
            var choose= document.getElementsByClassName("choose");
            if($('#selectall').is(':checked')) {
                choose[i].checked = true;
            }else{
                choose[i].checked = false;
            }
            document.getElementBy("form").submit();
        }
    </script>

</body>
</html>
